# Contributor: Yannick Ulrich <yannick.ulrich@durham.ac.uk>
# Contributor: Clayton Craft <clayton@craftyguy.net>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=waked
pkgver=0.1.1
pkgrel=4
license="GPL-2.0-or-later"
pkgdesc="Waked is a daemon which lets Apps wake the system from suspend at requested times"
arch="all"
url="https://gitlab.com/seath1/waked"
makedepends="cmake samurai sdbus-cpp-dev"
source="https://gitlab.com/seath1/waked/-/archive/v$pkgver/waked-v$pkgver.tar.bz2
	waked.initd
	0001-cmake-add-install-target.patch
	0002-Include-typedef-for-uint64_t-fixes-compilation.patch
	0003-use-relative-times-for-broken-RTCs.patch
	"
subpackages="$pkgname-openrc"
options="!check" # No test suite
builddir="$srcdir/$pkgname-v$pkgver"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		$CMAKE_CROSSOPTS

	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
	install -Dm755 "$srcdir"/waked.initd "$pkgdir"/etc/init.d/waked

	mkdir -p "$pkgdir"/usr/share/dbus-1/system.d/
	mv "$pkgdir"/etc/dbus-1/system.d/* "$pkgdir"/usr/share/dbus-1/system.d/
}

sha512sums="
8d0c3d659e7e8a8f4d8c0462871a234931d0e915935cdd119f79a8059ac74baba22ce9d12c1a376cad232a7ef79a8bdd35392f04c435ad8653ec8947ed170c37  waked-v0.1.1.tar.bz2
04364b519d7266859b151a12178c68e5837c8b6310f6b1ca7920d4163970dfd6310a7c4816ec81d0bfbd8ab9c9e93168ad5ef473b8ebc69304da45c0ca196f11  waked.initd
2de6b05dc8dcb5c526c2d419c022a728029dac390926413078eaf9347d7e018e73aa285256882bbbf35ecbdc2f0f277c3eff17ad5238e97e6e38d9bdaf310539  0001-cmake-add-install-target.patch
a932f341cafce2ef14112f1dd53888fea941ad2adfa5ff420ab8ef7ec10c08fd7afadbe0d2f0a8aba1cab963dc0a25d55daffb331f539879420d551106fce143  0002-Include-typedef-for-uint64_t-fixes-compilation.patch
38d14cabea4cde437f7825d86a628040ae0c0e37b380cf48da2364c0607a7fcf9746884299468b9f86f1c34dd80fadf6a3d37b98ff1fb18bbf9e31f7dc2733ea  0003-use-relative-times-for-broken-RTCs.patch
"
